package com.example.component;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.example.adapter.PopupInforAdapter;
import com.example.appcontact.A003Contact;
import com.example.appcontact.R;
import com.example.model.OutNotification;

public class PopupContentView extends AbstractPopupContentView implements
		OnClickListener {
	private ListView listview;
	private int height;
	private int width;
	private ImageView img_check;

	private LayoutInflater inflater;
	private OutNotification data;
	private String emailLogged;
	private ListView listView;
	private A003Contact A001;
	private ProgressBar progress;
	private TextView tvMessage;

	public PopupContentView(final Context context, int layout,
			A003Contact a003Contact, String emailLogged) {
		super(context, layout);

		this.emailLogged = emailLogged;
		this.A001 = a003Contact;
		Log.d("TAG_TOM", "Email Logged: " + emailLogged);
		createUI();
	}

	public void showMessage(String message) {
		progress.setVisibility(View.GONE);
		listView.setVisibility(View.GONE);
		tvMessage.setVisibility(View.VISIBLE);
		tvMessage.setText(message);
	}

	public void showProcess() {
		progress.setVisibility(View.VISIBLE);
		listView.setVisibility(View.GONE);
		tvMessage.setVisibility(View.GONE);
	}

	public void showData(OutNotification data) {
		this.data = data;
		progress.setVisibility(View.GONE);
		listView.setVisibility(View.VISIBLE);
		tvMessage.setVisibility(View.GONE);
		init();
	}

	public void SetLogged(String abc) {
		this.emailLogged = abc;
	}

	@Override
	public void createUI() {
		LayoutInflater inflater = (LayoutInflater) getContext()
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		this.inflater = inflater;
		v = inflater.inflate(id_Layout, this);
		listView = (ListView) v.findViewById(R.id.popup_view_listview);
		progress = (ProgressBar) v.findViewById(R.id.popup_progressbar);
		tvMessage = (TextView) v.findViewById(R.id.popup_tv_message);

	}

	@Override
	public void onClick(View v) {

	}

	@Override
	public void init() {
		this.initData();
	}

	private void initData() {
		PopupInforAdapter adapter = new PopupInforAdapter(A001,
				R.layout.item_popup_info, data.getOutInfications(), emailLogged);
		listView.setAdapter(adapter);
	}

}
